#ifndef __SPARSE_MATRIX_H
#define __SPARSE_MATRIX_H

#include "../Containers/NumList.h"

typedef double elem;

typedef struct cell_t
{
  struct cell_t *row_next;	/* pointer to the next element in the row.  */
  struct cell_t *col_next;	/* pointer to the next element in the column.  */
  int rowind;				/* index in row */
  int colind;				/* index in column */
  elem	value;				/* value of the elem.   */
} cell_t;					/* matrix cell data type */

typedef struct
{
  int n;				/* size */
  cell_t **rows;		/* array of row lists.  */
  cell_t **cols;		/* array of col lists.  */
} sparse_matrix_lst;	/* sparse matrix representation */

sparse_matrix_lst* allocate_sparse_matrix_lst(int n);
void free_sparse_matrix_lst(void* matrix);
void  mult_sparse_list(const sparse_matrix_lst *A, const elem* v, elem* result);
cell_t* InitCell(int rowInd, int colInd, elem value);
elem* DegVector(const sparse_matrix_lst* matrix, elem* vector);
elem SumRow(const sparse_matrix_lst* matrix, unsigned row);
sparse_matrix_lst* PartialMatrix (const sparse_matrix_lst* adjMatrix, const NumList* group);

#endif /* __SPARSE_MATRIX_H*/
